<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>微信关键字管理</title>
	<script src="../js/config.js"></script>
</head>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>crm</title>
	<link rel="stylesheet" type="text/css" href="../css/style.css">
	<link rel="stylesheet" type="text/css" href="../js/layer/theme/default/layer.css">
	<script type="text/javascript" src="../js/vue.js"></script>
	<script type="text/javascript" src="../js/filter.js"></script>
	<script type="text/javascript" src="../js/config.js"></script>
	<link href="../images/favicon.ico" rel="icon" type="image/x-icon" />
	<script type="text/javascript" src="../js/jquery-1.9.1.min.js"></script>
	<script type="text/javascript" src="../js/jquery.serializejson.js"></script>
	<script type="text/javascript" src="../js/layer/layer.js"></script>
	<script type="text/javascript" src="../js/paging.js"></script>
</head>
<body>
<div class="crm-content" id="keywordList">
	<a onclick="newWxKeyword()"  class="add-button  opr-url">新增关键字</a>
	<a href="../menu/menu_list.html"  class="add-button">微信菜单管理</a>
	<a href="../material/material_list.html"  class="add-button">微信素材管理</a>
	<a href="../keyword/keyword_list.html"  class="add-button">微信关键字管理</a>
	<table class="list-box">
		<tr>
			<th>关键字名称</th>
			<th>回复类型</th>
			<th>回复信息</th>
			<th>操作</th>
		</tr>
		<tr v-for="(re,index) in res">
			<td>{{re.keywordName}}</td>
			<td>{{re.keywordType == "text" ? '文本' : re.keywordType == "news" ? '图文' : re.keywordType == "image" ? '图片' : '视频'}}</td>
			<td v-html='re.keywordType == "text" ? re.keywordValue : re.keywordType == "news" ? "<a href=javascript:void(0); onclick=mediaView(this); data-media_id=\"" + re.keywordValue + "\">查看图文详情</a>" : re.keywordType == "image" ? "<a href=javascript:void(0); onclick=mediaView(this); data-media_id=\"" + re.keywordValue + "\">查看图片详情</a>" : "<a href=javascript:void(0); onclick=mediaView(this); data-media_id=\"" + re.keywordValue + "\">查看视频详情</a>"'></td>
			<td>
				<span class="over-small" v-bind:data-wxKeywordId="re.keywordId"  onclick="editWxKeyword(this)">编辑</span>
				<span class="over-small" v-bind:data-wxKeywordId="re.keywordId"  onclick="removeWxKeyword(this)">删除</span>
			</td>
		</tr>
	</table>
	<div id="page" class="page_div"></div>

	<!-- 新增微信关键字弹窗  -->
	<form class="cell-content" id="insertWxKeywordForm" style="display: none;" >
		<div class="cell">
			<label><span class="red">*</span>关键字名称</label>
			<input type="text" name="keywordName" id="keywordName">
		</div>
		<div class="cell">
			<label><span class="red">*</span>回复类型</label>
			<select name="keywordType" onchange="setkeywordType(this)">
				<option v-for="keywordType in keywordTypeList" v-bind:value="keywordType.value">{{keywordType.name}}</option>
			</select>
		</div>
		<div class="cell">
			<label><span class="red">*</span>回复信息</label>
			<input type="text" name="keywordValue" id="keywordValue">
		</div>
	</form>
	
	<!-- 修改微信关键字弹窗  -->
	<form class="cell-content" id="updateWxKeywordForm" style="display: none;" >
		<div class="cell">
			<label><span class="red">*</span>关键字名称</label>
			<input type="text" name="keywordName" id="keywordName"  v-model="wxRes.keywordName">
		</div>
		<div class="cell">
			<label><span class="red">*</span>回复类型</label>
			<select name="keywordType" onchange="setkeywordType(this)">
				<option v-for="keywordType in keywordTypeList" v-bind:value="keywordType.value">{{keywordType.name}}</option>
			</select>
		</div>
		<div class="cell">
			<label><span class="red">*</span>回复信息</label>
			<input type="text" name="keywordValue" id="keywordValue" v-model="wxRes.keywordValue">
		</div>
	</form>

</div>
	<div id="materialView" style="display: none;"></div>
	<script type="text/javascript">
		var wxKeywordList = new Vue({
			el:'#keywordList',
			data: {
				res:[],
				wxRes: [],
				keywordType : 'a',
				keywordTypeList: []
			},
			methods: {
				
			},
		})
        
		var pageIndexNow = 1;
		$.ajax({
			type: "get",      //data 传送数据类型。post 传递
			dataType: 'json',  // 返回数据的数据类型json
			url: wxUrl + "/selectWxKeywordNum",  // yii 控制器/方法
			cache: false,      
			error:function(){
			//alert("数据传输错误");
			},success: function (data) {
				console.log(data);
				if (data.code != 1) {
				return false
				}
				var pageTotal = data.result.total;
				var pageNumTotal = Math.ceil(pageTotal/20);
				$("#page").paging({
					pageNo:pageIndexNow,
					totalPage: pageNumTotal,
					totalSize: pageTotal,
					callback: function(num) {
						pageIndexNow = num;
						init(num)
					}
				});
			}
		});
		function init(pageIndex){
			wxKeywordList.keywordTypeList= [{name:'文本',value: 'text'}, {name:'图文',value: 'news'}, {name:'图片',value: 'image'}, {name:'视频',value: 'video'}]
			$.ajax({
				type: "get",      //data 传送数据类型。post 传递
				dataType: 'json',  // 返回数据的数据类型json
				url:  wxUrl + "/selectWxKeywordList",  // yii 控制器/方法
				data : {
					pageIndex : pageIndex,
					pageSize : 20,
				},
				cache: false,
				error:function(){
					// alert("数据传输错误");
				},success: function (data) {
					console.log(data);
					wxKeywordList.res = data.result;
				}
			});
		}

		init(1);
	</script>
	<script type="text/javascript" src="../js/wxMaterial.js"></script>
	<script type="text/javascript" src="../js/wxKeyword.js"></script>

</body>
</html>

